package vn.edu.uit.chemistry.model;

import vn.edu.uit.chemistry.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;

public class FakeGuiTaiLieuAdapter extends BaseAdapter {

	Context ctx;
	LayoutInflater mInflater;
	String[] hotens = {"Hoc Sinh A", "Hoc Sinh B"};
	String[] mshss = {"hs12345", "hs12346"};
	int[] dones = {1,0};
	
	public FakeGuiTaiLieuAdapter(Context _ctx) {
		this.ctx = _ctx;
		mInflater = LayoutInflater.from(_ctx);
	}
	
	public int getCount() {
		// TODO Auto-generated method stub
		return hotens.length;
	}

	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}
	
	public class GuiTLHolder {
		TextView tvHoten;
		TextView tvMshs;
		ProgressBar prPercent;
		ImageView tvDone;
	}

	public View getView(int pos, View v, ViewGroup arg2) {
		GuiTLHolder holder;
		if (v == null) {
			v = mInflater.inflate(R.layout.row_gui_tai_lieu, null);
			holder = new GuiTLHolder();
			holder.prPercent = (ProgressBar) v.findViewById(R.id.prPercent);
			holder.tvHoten = (TextView) v.findViewById(R.id.tvHoTen);
			holder.tvMshs = (TextView) v.findViewById(R.id.tvMSHS);
			holder.tvDone = (ImageView) v.findViewById(R.id.imgDiemDanh);

			v.setTag(holder);
		} else {
			holder = (GuiTLHolder) v.getTag();
		}
		
		holder.tvHoten.setText("Họ tên: " + hotens[pos]);
		holder.tvMshs.setText("MSHS: " + mshss[pos]);
		
		if (dones[pos] == 1) {
			holder.prPercent.setVisibility(View.GONE);
			holder.tvDone.setVisibility(View.VISIBLE);
		} else {
			holder.prPercent.setVisibility(View.VISIBLE);
			holder.tvDone.setVisibility(View.GONE);
		}
		return v;
	}

}
